package watki.tylko;

import java.text.NumberFormat;

public class TestSynchro implements Runnable {

	private int stanKonta = 0;
	
	@Override
	public void run() {

		for(int i = 0; i < 50; i++){
			inkrementuj();
			System.out.println("Stan konta = " + NumberFormat.getNumberInstance().format(stanKonta));
		}
	}

	private void inkrementuj() {

		int i = stanKonta;
		stanKonta = i + 1;
	}

	public static void main(String[] args) {

		Runnable zadanie = new TestSynchro();
		Thread w1 = new Thread(zadanie);
		Thread w2 = new Thread(zadanie);
		Thread w3 = new Thread(zadanie);
		Thread w4 = new Thread(zadanie);
		w1.start();
		w2.start();
		w3.start();
		w4.start();
	}

}
